home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Info-Mac 3
/
Info_Mac_1994-01.iso
/
Graphics
/
Utility
/
GL Viewer 1.1.1
/
src ƒ
/
macPrefsDLOG.c
< prev
next >
Wrap
Text File
|
1993-08-28
|
3KB
|
155 lines
/*
* Routine to run GL View options dialog.
*
* Copyright (c) 1993 by Martin W. Fong
*/
#include <stdlib.h>
#include "macPrefs.h"
enum
{
iOKOutline = Cancel + 1,
__iFirstDialogItem__,
iPrefSmallVideoC = __iFirstDialogItem__,
iPrefImageloop,
iPrefShowDirectory,
iPrefShowText,
iPrefPrintTheCodes,
iPrefQuiet,
iPrefVerbose,
iPrefImVerbose,
__iLastDialogItem__ = iPrefImVerbose
};
static pascal void DrawOutline (WindowPtr dialog, short item);
#define SET_CHECK_BOX(ithItem, value) \
{ \
if (__iFirstDialogItem__ <= ithItem && ithItem <= __iLastDialogItem__) \
{ \
GetDItem (dialog, ithItem, &iType, &hItem, &rect); \
if (iType & (ctrlItem | chkCtrl)) \
SetCtlValue ((ControlHandle) hItem, value); \
} \
}
#define TOGGLE_PREF_SETTING(ithItem) \
{ \
if (__iFirstDialogItem__ <= ithItem && ithItem <= __iLastDialogItem__) \
{ \
u_char aMask = 0x01 << (__iLastDialogItem__ - ithItem); \
\
\
if (newPrefs & aMask /* != 0 */) \
{ \
newPrefs &= ~aMask; \
SET_CHECK_BOX (ithItem, 0); \
} \
else \
{ \
newPrefs |= aMask; \
SET_CHECK_BOX (ithItem, 1); \
} \
} \
}
u_char
DoMacPrefsDialog (u_char origPrefs)
{
u_char newPrefs = origPrefs;
DialogPtr dialog = GetNewDialog (MACPREFSDLOG, (char *) NULL, (WindowPtr) -1);
if (dialog /* != (DialogPtr) NULL */)
{
short iType;
Handle hItem;
Rect rect;
Boolean fBreakLoop;
short ithItem;
u_char aMask;
/*...Prep outline field...*/
GetDItem (dialog, iOKOutline, &iType, &hItem, &rect);
if (iType == userItem | itemDisable)
SetDItem (dialog, iOKOutline, iType, (Handle) DrawOutline, &rect);
/*...Establish the defaults...*/
for (ithItem = __iLastDialogItem__, aMask = 0x01;
ithItem >= __iFirstDialogItem__;
ithItem--, aMask <<= 1)
{
if (origPrefs & aMask /* != 0 */)
SET_CHECK_BOX (ithItem, 1);
}
/*...Run the modal dialog...*/
ShowWindow (dialog);
for (fBreakLoop = FALSE; !fBreakLoop; )
{
short item;
ModalDialog ((ProcPtr) NULL, &item);
switch (item)
{
case Cancel:
newPrefs = origPrefs;
/* fall through */
case OK:
fBreakLoop = TRUE;
break;
default:
{
TOGGLE_PREF_SETTING (item);
break;
}
}
}
DisposDialog (dialog);
}
return newPrefs;
}
static pascal void
DrawOutline (WindowPtr dialog, short item)
{
short iType;
Handle hItem;
Rect rect;
GrafPtr savePort;
GetPort (&savePort);
SetPort ((GrafPtr) dialog);
GetDItem (dialog, item, &iType, &hItem, &rect);
PenSize (3, 3);
FrameRoundRect (&rect, 16, 16);
SetPort (savePort);
}